#ifndef LOG_HPP_INCLUDED
#define LOG_HPP_INCLUDED

#ifndef __func__
#ifdef __FUNCTION__
#define __func__ __FUNCTION__
#endif
#endif

#include <iostream>
#include <sstream>
#include <string>
#include <utility>

namespace lg
{
	typedef std::pair<const std::string, int> logd;

	class log_domain
	{
		logd* domain_;
	public:
		log_domain(char const* name);
		friend class logger;
	};

	class logger
	{
		char const* name_;
		int severity_;

	public:
		logger(char const* name, int severity) : name_(name), severity_(severity) {}
		std::ostream& operator() (log_domain const& domain,
			bool show_names = true, bool do_indent = false) const;

		bool dont_log(log_domain const &domain) const
		{
			return severity_ > domain.domain_->second;
		}
	};

	extern logger err, warn, info, debug;
	extern log_domain general;
}

#define LOG_STREAM(a, b) if (lg::a.dont_log(b)); else lg::a(b)

#endif
